#e
#Title[Pure Terror]
#Text[]
#Player[FREE]
#ScriptVersion[2]

script_enemy_main {
	#include_function ".\lib\lib_anime_Reisen.txt"
	#include_function ".\lib\function.txt"
	#include_function ".\boss.txt"
	let csd		=GetCurrentScriptDirectory;
	let shotData	=csd ~ ".\shot.txt";
	let imgBoss	=csd ~ "img\dot_reisen.png";
	let imgBG1	=csd ~ "img\maho1.png";
	let imgBG2	=csd ~ "img\maho2.png";
	let BGn		=0;
	let xIni	=GetCenterX;
	let yIni	=GetClipMinY + 100;
	let count	=0;
	@Initialize {
        CutIn(YOUMU,"Pure Terror", "", 0, 0, 0, 0);
        SetLife(2800);
	SetTimer(40);
	SetScore(100000);
	SetDamageRate(5, 5);
	InitializeAction();
	LoadUserShotData(shotData);
	LoadGraphic(imgBoss);
	LoadGraphic(imgBG1);
	LoadGraphic(imgBG2);
        TMain;
	}

	@MainLoop {
	BGn++;
        SetCollisionA(GetX, GetY, 32);
        SetCollisionB(GetX, GetY, 16);
	count++;
	yield;
	}

	@DrawLoop {
	SetColor(255,255,255);
	SetGraphicScale(1,1);
	SetAlpha(255);
	SetGraphicAngle(0,0,0);
	DrawBoss(imgBoss);
	BG;
	}

	@Finalize{
	}

    task TMain {
	yield;
	SetDamageRate(80,100);
	moveA;
	wait(120);
	loop{
	shotA;
	wait(90);
	shotB;
	wait(440);
	loop(6){
	put_bit_A(1,0);
	wait(90);
	put_bit_A(-1,180);
	wait(90);
	}
	wait(120);
	}
	}

	task put_bit_A(Ang,Ang2){
	let A=6;
	let B=Ang2;
	let C=10;
		loop(180/A){
			CreateEnemyFromScript("bit", GetX+cos(B)*(C*2), GetY+sin(B)*C, 2, B, 0);
		yield;
		B+=A*Ang;
		C+=4;
		}
	}


	task shotA {
	let A=60;
	let B=0;
	loop(6){
			wayShot(GetX+cos(B)*30,GetY+sin(B)*30,4,90+1,2,180,25,62,10);
			wayShot(GetX+cos(B)*30,GetY+sin(B)*30,4,90,2,180,30,62,10);
		B+=A;
		wait(10);
	}
	}

	task shotB{
	let A=2;
	loop(18){
	let S=6.5;
	let Ang=GetAngleToPlayer;
		loop(14){
			wayShot(GetX,GetY,S,Ang,15,A,40,22,10);
			S-=0.4;
		yield;
		}
	A++;
	}
	}


   task moveA {
	let wMove =280;
	loop{	
	SetAction(ACT_MOVE,wMove);
	moveToPlayer(rand(40, 120), rand(-40, 40), wMove,
		GetClipMinX + 48, GetClipMinY +  50,
		GetClipMaxX - 48, GetClipMinY + 80);
	wait(wMove);
	}
	}

function GetGapAngle(
	let x1,
	let y1,
	let x2,
	let y2
){
	return atan2(y2-y1,x2-x1);
}

}

script_enemy bit {

	#include_function ".\lib\function.txt"

	let csd		= GetCurrentScriptDirectory;
	let imgEy	= csd ~ ".\shot_all.png";
	let imgmaho3	= csd ~ ".\img\maho3.png";
	let imgmaho4	= csd ~ ".\img\maho4.png";
	let Angle	= GetAngle;
	let Arg		= GetArgument;
	let Alp		= 255;
	let SX		= 0;
	let tama	=csd ~ "img\tama.wav";

	@Initialize {
	SetLife(10);
	SetDamageRateEx(100, 0, 0, 0);
	SetScore(2000000);
	LoadGraphic(imgEy);
	LoadGraphic(imgmaho3);
	LoadGraphic(imgmaho4);
	LoadSE(tama);
	TMain;
	}

	@MainLoop {
	if(GetX <= 0 || GetX >= 448){VanishEnemy;}
	if(GetY <= - 72 || GetY >= 640){VanishEnemy;}
	SetCollisionB(GetX, GetY, 6);
	SetCollisionA(GetX, GetY, 16);
	yield;
	}

	@DrawLoop{

	SetGraphicRect(0, 0, 48, 48);
	SetGraphicAngle(0,0,GetAngle+90);
	SetGraphicScale(1,1);
	SetColor(255,255,255);
	SetAlpha(255);
	SetTexture(imgmaho3);
	DrawGraphic(GetX,GetY);

	SetGraphicRect(0, 0, 64, 64);
	SetGraphicAngle(0,0,GetAngle+90);
	SetGraphicScale(SX,1);
	SetColor(255,255,255);
	SetAlpha(255);
	SetTexture(imgmaho4);
	DrawGraphic(GetX,GetY);
	}

	@Finalize{
	attributeB();
	if(BeVanished==false){
	let S=2;
		loop(18){
			CreateShot01(GetX,GetY,S,GetAngle,46,0);
		S+=0.1;
		}
	}
	}

	task TMain {
		yield;
		let Ang=0;
		SetSpeed(0);
		shotA;
		loop(10){
			SX+=0.05;
			yield;
		}
		SetSpeed(5);
		SetAngle(GetAngle);
		}


//waye쐻
	task shotA{
		wait(10);
		loop{
			CreateShot01(GetX,GetY,rand(1,3),GetAngle+rand(-8,8),62,0);
		wait(2);
		}
	}
#include_function ".\zako.txt"
}